package com.org.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.org.pojo.Community;
import com.org.pojo.NormalUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName: NormalUserMapper
 * Package: com.org.mapper
 * Description:
 *
 * @Author Origin
 * @Create 2024/2/2 1:12
 * @Version 1.0
 */

@Mapper
public interface NormalUserMapper extends BaseMapper<NormalUser> {

    @Select("select * from normal_user where username = #{username}")
    NormalUser findByUsername(String username);

    @Update("update normal_user set phone = #{phone}, sex = #{sex}, community_id = #{communityId}, update_time = now() where id = #{id}")
    void update(NormalUser normalUser);

    @Update("update normal_user set user_pic = #{url}, update_time = now() where id = #{id}")
    void updateAvatar(String avatarUrl, Integer id);

    @Update("update normal_user set password = #{md5String}, update_time = now() where id = #{id}")
    void updatePwd(String md5String, Integer id);


    @Update("update normal_user set name = #{name}, sex = #{sex}, phone = #{phone}, identity_id = #{identityId}, identity_id_img = #{identityIdImg}" +
            ", age = #{age},state = '待审核实名认证信息', update_time = now() where id = #{id}")
    void updateIdentity(String name, String sex, String phone, String identityId, String identityIdImg, Integer age, Integer id);

    @Update("update normal_user set state=#{state}, update_time=now() where id=#{id}")
    void updatestate(Integer id, String state);


//    @Select("select * from normal_user where id=#{id}")
//    NormalUser selectById(Integer id);


}
